﻿Partial Public Class ErrorWindow
    Inherits System.Windows.Window


    Private m_ex As Exception = Nothing
    Private m_msg As String = ""
    Private m_detail As String = ""

    Public Property Ex() As Exception
        Get
            Ex = m_ex
        End Get
        Set(ByVal value As Exception)
            m_ex = value
            If value IsNot Nothing Then
                Me.ErrorTextBox.Text = (value.Message & Environment.NewLine & Environment.NewLine & value.StackTrace)
            End If
        End Set
    End Property

    Public Property Msg() As String
        Get
            Msg = m_msg
        End Get
        Set(ByVal value As String)
            m_msg = value
            Me.MsgTextBox.Text = value
        End Set
    End Property

    Public Property Detail() As String
        Get
            Return Me.m_detail
        End Get
        Set(ByVal value As String)
            m_detail = value
            Me.ErrorTextBox.Text = value
        End Set
    End Property

    '
    ' exception data call
    '
    Public Sub New(ByVal e As Exception)
        Me.InitializeComponent()
        If (Not e Is Nothing) Then
            Ex = e
        End If
    End Sub

    '
    ' Routine information (debug)
    '
    Public Sub New(ByVal strRoutine As String, ByVal e As Exception)
        Me.InitializeComponent()
        If strRoutine <> "" Then
            Msg = strRoutine
        End If
        If (Not e Is Nothing) Then
            Ex = e
        End If
    End Sub

    '
    ' message call
    '
    Public Sub New(ByVal message As String)
        Me.InitializeComponent()
        If message <> "" Then
            Msg = message
        End If
    End Sub

    Public Sub New(ByVal uri As Uri)
        Me.InitializeComponent()
        If (Not uri Is Nothing) Then
            Msg = ("Page not found: """ & uri.ToString & """")
        End If
    End Sub

    Public Sub New(ByVal message As String, ByVal details As String)
        Me.InitializeComponent()
        Msg = (message & Environment.NewLine)
        Detail = details
    End Sub

    Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        Me.DialogResult = True
    End Sub

End Class
